package com.wwp.tbshop.presenter;

import android.widget.Toast;

import com.wwp.tbshop.activity.cartactivity.CommitActivity;
import com.wwp.tbshop.model.bean.BaseBean;
import com.wwp.tbshop.model.bean.OrderSubmitResponseBean;
import com.wwp.tbshop.util.SPUtils;

import retrofit2.Call;

/**
 * Created by Administrator on 6/20/2017.
 */

public class CommitPresenter extends BasePresenter{


    public CommitActivity mCommitActivity;


    public CommitPresenter(String sku, String addressId, String paymentType,
                           String deliveryType, String invoiceType,
                           String invoiceTitle, String invoiceContent,CommitActivity commitActivity) {

        mCommitActivity = commitActivity;

        String uerid = SPUtils.getUerid();

        Call<OrderSubmitResponseBean> addressList = mApiService.submitOrder(uerid,sku,addressId,paymentType
        ,deliveryType,invoiceType,invoiceTitle,invoiceContent);

        addressList.enqueue(mCallback);

    }


    @Override
    protected void onServerBug(int code) {

    }

    @Override
    protected void onConnectError(String message) {
        Toast.makeText(mCommitActivity, "failed", Toast.LENGTH_SHORT).show();
    }

    @Override
    protected void onSuccess(BaseBean baseBean) {

        OrderSubmitResponseBean baseBean1 = (OrderSubmitResponseBean) baseBean;

        mCommitActivity.CommitSuceess(baseBean1);
    }
}
